<?php
/**
 * Created by PhpStorm.
 * User: idcu
 * Date: 2016/3/8
 * Time: 17:59
 */
namespace Service\Model;
use IDCU\Model\RelationModel;

class CustomerModel extends RelationModel
{
    protected $_link = array(
        'FamilyMember' => array(
            'mapping_type' => self::HAS_MANY,
            'class_name' => 'FamilyMember',
            'mapping_name' => 'family_member',
            'foreign_key' => 'customer_id'
        ),
        'Family' => array(
            'mapping_type' => self::MANY_TO_MANY,
            'class_name' => 'Family',
            'mapping_name' => 'families',
            'foreign_key' => 'customer_id',
            'relation_foreign_key' => 'family_id',
            'relation_table' => 'zh_family_member'
        ),
        'Order' => array(
            'mapping_type' => self::HAS_MANY,
            'class_name' => 'Order',
            'mapping_name' => 'orders',
            'foreign_key' => 'customer_id'
        )
    );

    protected function _after_select(&$resultSet, $options)
    {
        parent::_after_select($resultSet, $options); // TODO: Change the autogenerated stub
        D('Dict')->dictTransform($resultSet,array('ugroup'));
    }
}